import { uploadFile } from '@/api/system'
const chooseUpload = (type: Array<'image'>, sourceType: Array<'album'>) => {
  return new Promise((resolve, reject) => {
    wx.chooseMedia({
      count: 1, // 最多可选择1张图片
      mediaType: type,
      sourceType: sourceType,
      sizeType: ['original', 'compressed'],
      success: (res) => {
        const tempFiles = res.tempFiles
        const urls: string[] = []
        let counts = 0;
        tempFiles.forEach(ss => {
          counts = counts + 1
          uploadFile(ss.tempFilePath).then(res => {
            resolve(res);
            console.log("上传url：" + urls)
          })
        })
      }
    });
  })
}
export default chooseUpload